package com.gexiao.tx.dao;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void insert() {
//        String sql = "INSERT INTO `user`(name,password,age) VALUES(?,?,?)";
        String sql = "INSERT INTO `user`(name,password,age) VALUES('{}','{}',{})";

        String username = IdUtil.simpleUUID().substring(0, 5);
        String password = "1";
        Integer age = 11;
//        jdbcTemplate.update(sql,username,password,age);
        String real = StrUtil.format(sql, username, password, age);
        jdbcTemplate.execute(real);
    }
}
